{% extends 'admin/index.html' %}

{% block title %}
FuSite-博客管理
{% endblock %}

{% block content %}
<section class="section">
    <div class="container">
        <div class="columns">
            <div class="column is-8">
            {% if blogs != {} %}
                <div class="box is-shadowless is-radiusless">
                    <div class="tags has-addons is-pulled-right">
                        <span class="tag">共</span>
                        <span class="tag is-success">{{ all }} 篇</span>
                    </div>
                </div>
                {% for blog in blogs[page] %}
                <div class="box" onclick="window.open('/admin_blog/{{ blog.文章id }}')">
                    <h1 class="is-size-5 has-text-weight-bold">
                        <a>{{ blog['标题'] }}</a>
                    </h1>
                    <div class="is-size-7 has-text-grey-light pt-1 pb-1">
                        <span class="mr-3">作者:{{ blog['作者'] }}</span> <span>{{ blog['上传日期']|handle_time }}发布</span> <span>{{ blog['修改日期']|handle_time }}修改</span> <span>浏览量:{{ blog['浏览量'] }}</span>
                    </div>
                    <p class="mt-3">{{ blog['描述'] }}</p>
                </div>
                {% endfor %}
                <nav class="pagination is-centered" role="navigation">
                    {% if page != 1 %}
                        <a class="pagination-previous" href="?page={{ page-1 }}">上一页</a>
                    {% else %}
                        <a class="pagination-previous" href="" style="visibility: hidden;">上一页</a>
                    {% endif %}
                    {% if page != pages %}
                        <a class="pagination-next" href="?page={{ page+1 }}">下一页</a>
                    {% else %}
                        <a class="pagination-next" href="" style="visibility: hidden;">下一页</a>
                    {% endif %}
                    <ul class="pagination-list">
                        <li>
                            <a class="pagination-link" href="?page=1">1</a>
                        </li>
                        <li>
                            <span class="pagination-ellipsis">&hellip;</span>
                        </li>
                        {% if pages == 1 %}
                        <li>
                            <a class="pagination-link is-current" href="?page=1">1</a>
                        </li>
                        {% elif pages == 2 %}
                        <li>
                            {% if page == 1 %}
                                <a class="pagination-link is-current" href="?page=1">1</a>
                            {% else %}
                                <a class="pagination-link" href="?page=1">1</a>
                            {% endif %}
                        </li>
                        <li>
                            {% if page == 2 %}
                                <a class="pagination-link is-current" href="?page=2">2</a>
                            {% else %}
                                <a class="pagination-link" href="?page=2">2</a>
                            {% endif %}
                        </li>
                        {% else %}
                        <li>
                            {% if page == 1 %}
                                <a class="pagination-link is-current" href="?page=1">1</a>
                            {% elif page == pages %}
                                <a class="pagination-link" href="?page={{ page-2 }}">{{ page-2 }}</a>
                            {% else %}
                                <a class="pagination-link" href="?page={{ page-1 }}">{{ page-1 }}</a>
                            {% endif %}
                        </li>
                        <li>
                            {% if page == 1 %}
                                <a class="pagination-link" href="?page=2">2</a>
                            {% elif page == pages %}
                                <a class="pagination-link" href="?page={{ page-1 }}">{{ page-1 }}</a>
                            {% else %}
                                <a class="pagination-link is-current" href="?page={{ page }}">{{ page }}</a>
                            {% endif %}
                        </li>
                        <li>
                            {% if page == 1 %}
                                <a class="pagination-link" href="?page=3">3</a>
                            {% elif page == pages %}
                                <a class="pagination-link is-current" href="?page={{ page }}">{{ page }}</a>
                            {% else %}
                                <a class="pagination-link" href="?page={{ page+1 }}">{{ page+1 }}</a>
                            {% endif %}
                        </li>
                        {% endif %}
                        <li>
                            <span class="pagination-ellipsis">&hellip;</span>
                        </li>
                        <li>
                            <a class="pagination-link" href="?page={{ pages }}">{{ pages }}</a>
                        </li>
                    </ul>
                </nav>
                {% else %}
                    <div class="box">
                        <h1 class="title has-text-danger is-size-4">暂无文章!</h1>
                    </div>
                {% endif %}
            </div>
            <div class="column is-4">
                <div class="box">
                    <h1 class="is-size-5 title">搜索</h1>
                    <div>
                        <form action="/admin_blog/search">
                            <div class="field has-addons">
                                <div class="control is-expanded">
                                    <input type="search" class="input is-success" name="keyword" placeholder="关键字" value="{{ keyword }}">
                                </div>
                                <div class="control">
                                    <input class="button is-success" type="submit" value="搜索">
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
                <div class="box">
                    <h1 class="is-size-5 title">操作</h1>
                    <button class="button is-success is-fullwidth" onclick="window.open('/admin/add_blog')">添加文章</button>
                </div>
            </div>
        </div>
    </div>
</section>

{% endblock %}
